Customer Checkout Blacklist v1.2 for osCommerce BootStrap

/////////////////////////////////////////////////////////////

This module will help block potentially fraudulent customers 
checking out on your shop and preventing future chargebacks
whilst retaining the customer on the store to keep a record
of the transactions and to be able to communicate with said
customer.
Can be used to place customers accounts on hold if they use
a credit account to prevent them making further purchases
without having paid your invoices.

To use this module, login to your admin panel, go to
customers, find said customer and edit. At the bottom of the
page you will see the option header 
"Prevent Customer Checking out (Blacklisted)?" Change the
option to "Yes". When a customer attempts to checkout from
the shopping cart, they will be redirected to the 
"Account on Hold" page. 
Note: Page described as account on hold, as best not to 
say your customer is blacklisted, if they turn out to be
innocent, and since this can be used to hold an account, 
positivity is better than negativity.

Developed By: Sean McCabe (DT Tech Ltd)

Created: 06/03/2014

Adapted BootStrap by reflex-ocasion (10/21/2016)

Version 1.2

//MODIFIES THE FOLLOWING FILES
catalog/checkout_shipping.php
catalog/admin/customers.php
catalog/admin/includes/languages/english/customers.php
catalog/admin/includes/languages/espanol/customers.php

//ADDS THE FILES
catalog/account_hold.php
catalog/includes/languages/english/account_hold.php
catalog/includes/languages/espanol/account_hold.php

/////////////////////////////////////////////////////////////


--------------------------------------------------------------------------
1. Perform the SQL query to your osCommerce database.
--------------------------------------------------------------------------
ALTER TABLE  `customers` ADD  `customers_blacklist` TINYINT( 1 ) NOT NULL DEFAULT  '0';


--------------------------------------------------------------------------
2. Modify the catalog/checkout_shipping.php file.
--------------------------------------------------------------------------
Find:
-----

// if there is nothing in the customers cart, redirect them to the shopping cart page
  if ($cart->count_contents() < 1) {
    tep_redirect(tep_href_link('shopping_cart.php'));
  }


Add after:
----------

//check to see if customer has been blacklisted from checkingout.
  $check_blacklist_query = tep_db_query("select customers_blacklist from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
  $check_blacklist = tep_db_fetch_array($check_blacklist_query);

  if ($check_blacklist['customers_blacklist'] == '1') {
    tep_redirect(tep_href_link('account_hold.php'));
  }


--------------------------------------------------------------------------
3. Upload the following.
--------------------------------------------------------------------------
catalog/account_hold.php
catalog/includes/languages/english/account_hold.php
catalog/includes/languages/espanol/account_hold.php

** YOU CAN MODIFY THE CONTENTS OF THE FILE TO SUIT YOUR NEEDS, JUST CHANGE THE TEXT IN THE LANGUAGE AS PER THE USUAL INSTRUCTION FOR MODIFYING PAGE TEXT **


--------------------------------------------------------------------------
4. Modify the catalog/admin/customers.php file.
--------------------------------------------------------------------------
Find (around line 29):
----

    $customers_newsletter = tep_db_prepare_input($HTTP_POST_VARS['customers_newsletter']);


Add after:
----------

    $customers_blacklist = tep_db_prepare_input($HTTP_POST_VARS['customers_blacklist']); // Customer Blacklist



Find: 
-----

	'customers_newsletter' => $customers_newsletter);

	
Replace With:
-------------

	'customers_newsletter' => $customers_newsletter,
	'customers_blacklist' => $customers_blacklist);	// Customer Blacklist


	
Find:
-----

	 $customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'");


Replace With:
-------------

	//Customer Blacklist Replaced the Query
	$customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_blacklist, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'");



Find:
-----

	$newsletter_array = array(array('id' => '1', 'text' => ENTRY_NEWSLETTER_YES),
                                  array('id' => '0', 'text' => ENTRY_NEWSLETTER_NO));
							  
Add After:
----------

	// BOF: Customer Checkout Blacklist
        $blacklist_array = array(array('id' => '1', 'text' => ENTRY_CUSTOMER_BLACKLIST_YES),
                                 array('id' => '0', 'text' => ENTRY_CUSTOMER_BLACKLIST_NO));
	// EOF: Customer Checkout Blacklist



Find:
-----
	<?php
	  if ($processed == true) {
		if ($cInfo->customers_newsletter == '1') {
		  echo ENTRY_NEWSLETTER_YES;
		} else {
		  echo ENTRY_NEWSLETTER_NO;
		}
		echo tep_draw_hidden_field('customers_newsletter');
	  } else {
		echo tep_draw_pull_down_menu('customers_newsletter', $newsletter_array, (($cInfo->customers_newsletter == '1') ? '1' : '0'));
	  }
	?></td>
          </tr>
        </table></td>


Add BEFORE:
-----------

<!-- BOF Customer Blacklist //-->
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td class="formAreaTitle"><?php echo CUSTOMER_BLACKLIST; ?></td>
      </tr>
      <tr>
        <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
          <tr>
            <td class="main"><?php echo ENTRY_CUSTOMER_BLACKLIST; ?></td>
            <td class="main">
	<?php
	  if ($processed == true) {
		if ($cInfo->customers_blacklist == '1') {
		  echo ENTRY_CUSTOMER_BLACKLIST_YES;
		} else {
		  echo ENTRY_CUSTOMER_BLACKLIST_NO;
		}
		echo tep_draw_hidden_field('customers_blacklist');
	  } else {
		echo tep_draw_pull_down_menu('customers_blacklist', $blacklist_array, (($cInfo->customers_blacklist == '1') ? '1' : '0'));
	  }
	?></td>
			  </tr>
			</table></td>
<!-- EOF Customer Blacklist //-->


----------------
--- OPTIONAL ---
----------------

Find:
-----

    $customers_query_raw = "select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address, a.entry_country_id, a.entry_zone_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id " . $search . " order by $order";


Replace With:
-------------

    $customers_query_raw = "select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address, a.entry_country_id, a.entry_zone_id, c.customers_blacklist from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id " . $search . " order by $order";



Find:
-----

        $contents[] = array('align' => 'center', 'text' => tep_draw_button(IMAGE_EDIT, 'document', tep_href_link('customers.php', tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=edit')) . tep_draw_button(IMAGE_DELETE, 'trash', tep_href_link('customers.php', tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=confirm')) . tep_draw_button(IMAGE_ORDERS, 'cart', tep_href_link('orders.php', 'cID=' . $cInfo->customers_id)) . tep_draw_button(IMAGE_EMAIL, 'mail-closed', tep_href_link('mail.php', 'customer=' . $cInfo->customers_email_address)));


Add After:
----------

        if ($cInfo->customers_blacklist == '1') {
	      $customers_blacklist_indicator = ENTRY_CUSTOMER_BLACKLIST_YES;
	    } else {
	      $customers_blacklist_indicator = ENTRY_CUSTOMER_BLACKLIST_NO;
	    }
        $contents[] = array('text' => '<br />' . ENTRY_CUSTOMER_BLACKLIST . ' ' . $customers_blacklist_indicator);


--------------------------------------------------------------------------
5. Modify the catalog/admin/includes/languages/english/customers.php file.
--------------------------------------------------------------------------
Add before the last ?>:

	// BOF: Customer Blacklist
        define('CUSTOMER_BLACKLIST','Blacklisted');
        define('ENTRY_CUSTOMER_BLACKLIST','Customer Blacklisted?');
	define('ENTRY_CUSTOMER_BLACKLIST_YES','Yes');
	define('ENTRY_CUSTOMER_BLACKLIST_NO','No');
	// EOF: Customer Blacklist


--------------------------------------------------------------------------
6. Modify the catalog/admin/includes/languages/espanol/customers.php file.
--------------------------------------------------------------------------
Add before the last ?>:

	// BOF: Customer Blacklist
        define('CUSTOMER_BLACKLIST','Lista negra');
	define('ENTRY_CUSTOMER_BLACKLIST','Cliente en lista negra?');
	define('ENTRY_CUSTOMER_BLACKLIST_YES','Si');
	define('ENTRY_CUSTOMER_BLACKLIST_NO','No');

	// EOF: Customer Blacklist


-------------------------------------------------------------------------

